package com.smh.demo1.a37;

import com.smh.demo1.common.LogColour;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;

/**
 * @author shiminghui
 * @date 2025/5/9 19:43
 * @description: TODO
 */
public class Bean2 implements ApplicationContextAware {

    @Autowired
    private Bean1 bean1;

    @PostConstruct
    public void init() {
        System.out.println(LogColour.Green("Bean2 init()"));
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println(LogColour.Green(applicationContext.toString()));
    }

    @Override
    public String toString() {
        return "Bean2{" +
                "bean1=" + bean1 +
                '}';
    }
}
